archangel 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -2
  3. data/Gemfile +1 -1
  4. data/README.md +3 -3
  5. data/Rakefile +10 -7
  6. data/app/controllers/archangel/backend/sites_controller.rb +1 -2
  7. data/app/controllers/archangel/backend/users_controller.rb +1 -1
  8. data/app/controllers/concerns/archangel/seoable_concern.rb +1 -2
  9. data/app/models/archangel/entry.rb +1 -1
  10. data/app/models/archangel/page.rb +2 -4
  11. data/app/models/archangel/site.rb +0 -4
  12. data/app/models/archangel/template.rb +9 -0
  13. data/app/themes/default/assets/javascripts/default/backend.js +1 -0
  14. data/app/themes/default/assets/javascripts/default/backend/templates.js +26 -0
  15. data/app/themes/default/assets/stylesheets/default/auth/core.scss +10 -5
  16. data/app/themes/default/assets/stylesheets/default/backend/bootstrap/_tables.scss +40 -0
  17. data/app/themes/default/assets/stylesheets/default/backend/core.scss +11 -10
  18. data/app/themes/default/assets/stylesheets/default/frontend/core.scss +10 -5
  19. data/app/themes/default/views/layouts/auth.html.erb +0 -2
  20. data/app/themes/default/views/layouts/backend.html.erb +0 -2
  21. data/app/views/archangel/backend/assets/_asset.html.erb +12 -0
  22. data/app/views/archangel/backend/assets/index.html.erb +1 -14
  23. data/app/views/archangel/backend/collections/_collection.html.erb +10 -0
  24. data/app/views/archangel/backend/collections/index.html.erb +1 -12
  25. data/app/views/archangel/backend/entries/_entry.html.erb +13 -0
  26. data/app/views/archangel/backend/entries/index.html.erb +1 -15
  27. data/app/views/archangel/backend/pages/_page.html.erb +17 -0
  28. data/app/views/archangel/backend/pages/index.html.erb +1 -19
  29. data/app/views/archangel/backend/sites/_form.html.erb +0 -6
  30. data/app/views/archangel/backend/templates/_template.html.erb +10 -0
  31. data/app/views/archangel/backend/templates/index.html.erb +1 -12
  32. data/app/views/archangel/backend/users/_user.html.erb +11 -0
  33. data/app/views/archangel/backend/users/index.html.erb +1 -13
  34. data/app/views/archangel/backend/widgets/_widget.html.erb +10 -0
  35. data/app/views/archangel/backend/widgets/index.html.erb +1 -12
  36. data/bin/citest +3 -0
  37. data/bin/test +4 -0
  38. data/config/locales/active_record.en.yml +0 -2
  39. data/config/locales/en.yml +3 -3
  40. data/db/migrate/20171003191001_create_archangel_sites.rb +0 -1
  41. data/docs/Developers.md +2 -11
  42. data/docs/Extension/Developers.md +1 -1
  43. data/docs/Release.md +7 -1
  44. data/lib/archangel.rb +13 -0
  45. data/lib/archangel/command/templates/extension/Gemfile +0 -1
  46. data/lib/archangel/command/templates/extension/README.md +2 -11
  47. data/lib/archangel/command/templates/extension/Rakefile +4 -0
  48. data/lib/archangel/config.rb +5 -3
  49. data/lib/archangel/engine.rb +1 -1
  50. data/lib/archangel/liquid/drop.rb +1 -67
  51. data/lib/archangel/liquid/drops/site_drop.rb +0 -8
  52. data/lib/archangel/testing_support/factories/archangel_assets.rb +0 -5
  53. data/lib/archangel/testing_support/factories/archangel_sites.rb +0 -4
  54. data/lib/archangel/testing_support/support.rb +0 -4
  55. data/lib/archangel/version.rb +1 -1
  56. data/lib/generators/archangel/dummy/dummy_generator.rb +49 -27
  57. data/lib/generators/archangel/dummy/templates/config/database.yml +1 -1
  58. data/lib/generators/archangel/install/templates/config/archangel.yml +1 -18
  59. data/spec/controllers/archangel/backend/assets_controller_spec.rb +0 -11
  60. data/spec/controllers/archangel/backend/sites_controller_spec.rb +0 -16
  61. data/spec/features/backend/{duplicate_page_slugs_spec.rb → pages/duplicate_slugs_spec.rb} +0 -0
  62. data/spec/features/frontend/{drop_variables_spec.rb → liquid_drop_variables_spec.rb} +0 -2
  63. data/spec/features/frontend/{homepage_redirect_spec.rb → pages/homepage_redirect_spec.rb} +0 -0
  64. data/spec/lib/archangel/liquid/drops/site_drop_spec.rb +0 -5
  65. data/spec/lib/archangel/liquid/tags/asset_tag_spec.rb +2 -1
  66. data/spec/models/archangel/entry_spec.rb +4 -4
  67. data/spec/models/archangel/page_spec.rb +4 -4
  68. data/spec/models/archangel/template_spec.rb +14 -0
  69. data/spec/support/.keep +0 -0
  70. data/spec/uploaders/archangel/asset_uploader_spec.rb +1 -24
  71. data/vendor/assets/stylesheets/daterangepicker/_daterangepicker.scss +0 -2
  72. metadata +17 -10
  73. data/app/assets/images/archangel/fallback/favicon.ico +0 -0
  74. data/app/uploaders/archangel/favicon_uploader.rb +0 -38
  75. data/docs/Extension/Ideas.md +0 -133
  76. data/spec/support/coveralls.rb +0 -5
  77. data/spec/uploaders/archangel/favicon_uploader_spec.rb +0 -39
@@ -0,0 +1,13 @@
1
+ <tr class="entry-<%= entry.status %>" data-id="<%= entry.id %>">
2
+ <td class="text-center"><%= fa_icon("sort", title: Archangel.t(:sort)) %></td>
3
+ <% fields.each do |field| %>
4
+ <td><%= entry.value[field] %></td>
5
+ <% end %>
6
+ <td><%= entry.available_at %></td>
7
+ <td class="actions text-right">
8
+ <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_collection_entry_path(entry.collection, entry), class: "btn btn-info btn-sm") %>
9
+ <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_collection_entry_path(entry.collection, entry), class: "btn btn-warning btn-sm") %>
10
+ <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_collection_entry_path(entry.collection, entry), class: "btn btn-danger btn-sm",
11
+ method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
12
+ </td>
13
+ </tr>
@@ -33,21 +33,7 @@
33
33
  </thead>
34
34
 
35
35
  <tbody id="sortable">
36
- <% @entries.each do |entry| %>
37
- <tr class="<%= entry.available_status %>" data-id="<%= entry.id %>">
38
- <td class="text-center"><%= fa_icon("sort", title: Archangel.t(:sort)) %></td>
39
- <% fields.each do |field| %>
40
- <td><%= entry.value[field] %></td>
41
- <% end %>
42
- <td><%= entry.available_at %></td>
43
- <td class="actions text-right">
44
- <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_collection_entry_path(entry.collection, entry), class: "btn btn-info btn-sm") %>
45
- <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_collection_entry_path(entry.collection, entry), class: "btn btn-warning btn-sm") %>
46
- <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_collection_entry_path(entry.collection, entry), class: "btn btn-danger btn-sm",
47
- method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
48
- </td>
49
- </tr>
50
- <% end %>
36
+ <%= render partial: "entry", collection: @entries, locals: { fields: fields } %>
51
37
  </tbody>
52
38
  </table>
53
39
  </div>
@@ -0,0 +1,17 @@
1
+ <tr class="page-<%= page.status %>">
2
+ <td>
3
+ <%= page.title %>
4
+
5
+ <%= fa_icon("home") if page.homepage? %>
6
+ </td>
7
+ <td>
8
+ <%= URI.decode(frontend_page_path(page.path)) %>
9
+ </td>
10
+ <td><%= page.published_at %></td>
11
+ <td class="actions text-right">
12
+ <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_page_path(page), class: "btn btn-info btn-sm") %>
13
+ <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_page_path(page), class: "btn btn-warning btn-sm") %>
14
+ <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_page_path(page), class: "btn btn-danger btn-sm",
15
+ method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
16
+ </td>
17
+ </tr>
@@ -29,25 +29,7 @@
29
29
  </thead>
30
30
 
31
31
  <tbody>
32
- <% @pages.each do |page| %>
33
- <tr class="<%= page.published_status %>">
34
- <td>
35
- <%= page.title %>
36
-
37
- <%= fa_icon("home") if page.homepage? %>
38
- </td>
39
- <td>
40
- <%= URI.decode(frontend_page_path(page.path)) %>
41
- </td>
42
- <td><%= page.published_at %></td>
43
- <td class="actions text-right">
44
- <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_page_path(page), class: "btn btn-info btn-sm") %>
45
- <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_page_path(page), class: "btn btn-warning btn-sm") %>
46
- <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_page_path(page), class: "btn btn-danger btn-sm",
47
- method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
48
- </td>
49
- </tr>
50
- <% end %>
32
+ <%= render partial: "page", collection: @pages %>
51
33
  </tbody>
52
34
  </table>
53
35
  </div>
@@ -21,12 +21,6 @@
21
21
  <%= f.input :theme, as: :theme %>
22
22
  <%= f.input :locale, as: :language %>
23
23
 
24
- <%= f.input :favicon, as: :file %>
25
- <%= f.input :favicon_cache, as: :hidden %>
26
- <%= f.input :remove_favicon, as: :boolean,
27
- checked_value: true,
28
- unchecked_value: false if f.object.favicon? %>
29
-
30
24
  <%= f.input :meta_keywords, as: :meta_keywords %>
31
25
  <%= f.input :meta_description %>
32
26
  </div>
@@ -0,0 +1,10 @@
1
+ <tr class="template-<%= template.status %>">
2
+ <td><%= template.name %></td>
3
+ <td><%= template.partial? %></td>
4
+ <td class="actions text-right">
5
+ <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_template_path(template), class: "btn btn-info btn-sm") %>
6
+ <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_template_path(template), class: "btn btn-warning btn-sm") %>
7
+ <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_template_path(template), class: "btn btn-danger btn-sm",
8
+ method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
9
+ </td>
10
+ </tr>
@@ -28,18 +28,7 @@
28
28
  </thead>
29
29
 
30
30
  <tbody>
31
- <% @templates.each do |template| %>
32
- <tr>
33
- <td><%= template.name %></td>
34
- <td><%= template.partial? %></td>
35
- <td class="actions text-right">
36
- <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_template_path(template), class: "btn btn-info btn-sm") %>
37
- <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_template_path(template), class: "btn btn-warning btn-sm") %>
38
- <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_template_path(template), class: "btn btn-danger btn-sm",
39
- method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
40
- </td>
41
- </tr>
42
- <% end %>
31
+ <%= render partial: "template", collection: @templates %>
43
32
  </tbody>
44
33
  </table>
45
34
  </div>
@@ -0,0 +1,11 @@
1
+ <tr>
2
+ <td class="text-center"><%= image_tag(user.avatar.tiny.url, class: "img-center img-circle img-responsive", alt: user.username) %></td>
3
+ <td><%= user.name %></td>
4
+ <td><%= user.username %></td>
5
+ <td class="actions text-right">
6
+ <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_user_path(user), class: "btn btn-info btn-sm") %>
7
+ <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_user_path(user), class: "btn btn-warning btn-sm") %>
8
+ <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_user_path(user), class: "btn btn-danger btn-sm",
9
+ method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
10
+ </td>
11
+ </tr>
@@ -29,19 +29,7 @@
29
29
  </thead>
30
30
 
31
31
  <tbody>
32
- <% @users.each do |user| %>
33
- <tr>
34
- <td class="text-center"><%= image_tag(user.avatar.tiny.url, class: "img-center img-circle img-responsive", alt: user.username) %></td>
35
- <td><%= user.name %></td>
36
- <td><%= user.username %></td>
37
- <td class="actions text-right">
38
- <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_user_path(user), class: "btn btn-info btn-sm") %>
39
- <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_user_path(user), class: "btn btn-warning btn-sm") %>
40
- <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_user_path(user), class: "btn btn-danger btn-sm",
41
- method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
42
- </td>
43
- </tr>
44
- <% end %>
32
+ <%= render partial: "user", collection: @users %>
45
33
  </tbody>
46
34
  </table>
47
35
  </div>
@@ -0,0 +1,10 @@
1
+ <tr>
2
+ <td><%= widget.name %></td>
3
+ <td><%= widget.slug %></td>
4
+ <td class="actions text-right">
5
+ <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_widget_path(widget), class: "btn btn-info btn-sm") %>
6
+ <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_widget_path(widget), class: "btn btn-warning btn-sm") %>
7
+ <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_widget_path(widget), class: "btn btn-danger btn-sm",
8
+ method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
9
+ </td>
10
+ </tr>
@@ -28,18 +28,7 @@
28
28
  </thead>
29
29
 
30
30
  <tbody>
31
- <% @widgets.each do |widget| %>
32
- <tr>
33
- <td><%= widget.name %></td>
34
- <td><%= widget.slug %></td>
35
- <td class="actions text-right">
36
- <%= link_to(fa_icon("info-circle", text: Archangel.t(:show)), backend_widget_path(widget), class: "btn btn-info btn-sm") %>
37
- <%= link_to(fa_icon("check-circle", text: Archangel.t(:edit)), edit_backend_widget_path(widget), class: "btn btn-warning btn-sm") %>
38
- <%= link_to(fa_icon("times-circle", text: Archangel.t(:destroy)), backend_widget_path(widget), class: "btn btn-danger btn-sm",
39
- method: :delete, data: { confirm: Archangel.t(:are_you_sure) }) %>
40
- </td>
41
- </tr>
42
- <% end %>
31
+ <%= render partial: "widget", collection: @widgets %>
43
32
  </tbody>
44
33
  </table>
45
34
  </div>
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ bin/test
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ bundle exec rake dummy_app
4
+ bundle exec rake test
@@ -53,12 +53,10 @@ en:
53
53
  template_id: Template
54
54
  title: Title
55
55
  archangel/site:
56
- favicon: Favicon
57
56
  logo: Logo
58
57
  meta_description: META Description
59
58
  meta_keywords: META Keywords
60
59
  name: Name
61
- remove_favicon: Remove Favicon
62
60
  remove_logo: Remove Logo
63
61
  theme: Theme
64
62
  archangel/template:
@@ -24,9 +24,9 @@ en:
24
24
  cancel: Cancel
25
25
  custom_range: Custom
26
26
  date_format: "%Y-%m-%d"
27
- date_format_js: YYYY-MM-DD
27
+ date_format_js: "YYYY-MM-DD"
28
28
  datetime_format: "%Y-%m-%d %H:%M"
29
- datetime_format_js: YYYY-MM-DD HH:MM
29
+ datetime_format_js: "YYYY-MM-DD HH:MM"
30
30
  days:
31
31
  sunday: Sun
32
32
  monday: Mon
@@ -51,7 +51,7 @@ en:
51
51
  december: December
52
52
  separator: " - "
53
53
  time_format: "%H:%M"
54
- time_format_js: HH:MM
54
+ time_format_js: "HH:MM"
55
55
  to: To
56
56
  week: W
57
57
  destroy: Destroy
@@ -5,7 +5,6 @@ class CreateArchangelSites < ActiveRecord::Migration[5.1]
5
5
  t.string :theme
6
6
  t.string :locale, null: false, default: "en"
7
7
  t.string :logo
8
- t.string :favicon
9
8
  t.string :meta_keywords
10
9
  t.string :meta_description
11
10
  t.datetime :deleted_at
@@ -16,21 +16,12 @@ Generate a dummy application. You will be required to generate a dummy applicati
16
16
  $ bundle exec rake dummy_app
17
17
  ```
18
18
 
19
- Run tests
19
+ Run tests with any of the following
20
20
 
21
21
  ```
22
22
  $ bundle exec rake
23
- ```
24
-
25
- or
26
-
27
- ```
28
23
  $ bundle exec rake spec
29
- ```
30
-
31
- or
32
-
33
- ```
24
+ $ bundle exec rake test
34
25
  $ bundle exec rspec spec
35
26
  ```
36
27
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Extensions are meant to extend the functionality of Archangel. Documentation for theme development is [also available](https://github.com/archangel/archangel/blob/master/docs/Theme/Developers.md).
4
4
 
5
- Feeling bored? Looking for ideas? Take a look at possible [ideas for extensions](https://github.com/archangel/archangel/blob/master/docs/Extension/Ideas.md).
5
+ Bored? Take a look at the [TODO list for Archangel](https://trello.com/b/iAeANJRl).
6
6
 
7
7
  ## Generate an extension
8
8
 
@@ -14,7 +14,13 @@
14
14
  * `1.3.0-beta`
15
15
  * `2.0.0-rc.1`
16
16
 
17
- 2. Build the gem
17
+ a. If this is a major or minor version update, change the `README.md` file to reflect the version
18
+
19
+ ```
20
+ gem "archangel", "~> x.y"
21
+ ```
22
+
23
+ 3. Build the gem
18
24
 
19
25
  ```
20
26
  $ bundle exec rake build
@@ -88,5 +88,18 @@ module Archangel
88
88
  def themes
89
89
  [THEME_DEFAULT] + THEMES
90
90
  end
91
+
92
+ ##
93
+ # Reserved keywords for page slugs
94
+ #
95
+ # This is an array keywords that are not allowed to be used for Page slugs.
96
+ #
97
+ # Example
98
+ # Archangel.reserved_page_keywords #=> ["auth", "backend", ""]
99
+ #
100
+ # @return [Array] reserved keywords for page slugs
101
+ def reserved_page_keywords
102
+ %i[auth_path backend_path frontend_path]
103
+ end
91
104
  end
92
105
  end
@@ -16,7 +16,6 @@ end
16
16
 
17
17
  group :test do
18
18
  gem "capybara", "~> 2.17"
19
- gem "coveralls", "~> 0.8"
20
19
  gem "database_cleaner", "~> 1.6"
21
20
  gem "factory_bot_rails", "~> 4.8"
22
21
  gem "launchy", "~> 2.4"
@@ -46,21 +46,12 @@ First, generate a dummy application. You will be required to generate a dummy ap
46
46
  $ bundle exec rake dummy_app
47
47
  ```
48
48
 
49
- Run tests
49
+ Run tests with any of the following
50
50
 
51
51
  ```
52
52
  $ bundle exec rake
53
- ```
54
-
55
- or
56
-
57
- ```
58
53
  $ bundle exec rake spec
59
- ```
60
-
61
- or
62
-
63
- ```
54
+ $ bundle exec rake test
64
55
  $ bundle exec rspec spec
65
56
  ```
66
57
 
@@ -19,7 +19,11 @@ task default: :spec
19
19
 
20
20
  desc "Generates a dummy app for testing"
21
21
  task :dummy_app do
22
+ # ENV["DB"] = "sqlite3" # mysql, postgresql, sqlite3, etc
22
23
  ENV["LIB_NAME"] = "<%= extension_name %>"
23
24
 
24
25
  Rake::Task["dummy:generate"].invoke
25
26
  end
27
+
28
+ desc "Run RSpec tests"
29
+ task test: :spec
@@ -9,13 +9,15 @@ module Archangel
9
9
 
10
10
  attr_config allow_registration: false,
11
11
  asset_maximum_file_size: 2.megabytes,
12
- asset_extension_whitelist: %i[css gif jpeg jpg js png],
12
+ asset_extension_whitelist: %i[gif jpeg jpg png],
13
13
  auth_path: "account",
14
14
  backend_path: "backend",
15
- favicon_extension_whitelist: %i[gif ico jpeg jpg png],
16
- favicon_maximum_file_size: 2.megabytes,
17
15
  frontend_path: "",
18
16
  image_extension_whitelist: %i[gif jpeg jpg png],
19
17
  image_maximum_file_size: 2.megabytes
18
+
19
+ def keys_in(keys)
20
+ to_h.select { |key| keys.include?(key) }
21
+ end
20
22
  end
21
23
  end
@@ -6,7 +6,7 @@ module Archangel
6
6
  #
7
7
  class Engine < ::Rails::Engine
8
8
  isolate_namespace Archangel
9
- engine_name "archangel"
9
+ engine_name :archangel
10
10
 
11
11
  require "responders"
12
12
 
@@ -10,8 +10,8 @@ module Archangel
10
10
  #
11
11
  class Drop < ::Liquid::Drop
12
12
  class << self
13
- attr_accessor :_attributes
14
13
  attr_accessor :_associations
14
+ attr_accessor :_attributes
15
15
  end
16
16
 
17
17
  def self.inherited(base)
@@ -31,68 +31,6 @@ module Archangel
31
31
  end
32
32
  end
33
33
 
34
- def self.drop_class_for(resource)
35
- if self == Archangel::Liquid::Drop
36
- resource.drop_class || Archangel::Liquid::Drop
37
- else
38
- self
39
- end
40
- end
41
-
42
- def self.dropify(resource, options = {})
43
- class_name = options[:class_name]
44
-
45
- drop_class = if class_name
46
- class_name.constantize
47
- else
48
- drop_class_for(resource)
49
- end
50
-
51
- drop_class.new(resource, options.except(:class_name))
52
- end
53
-
54
- def self.belongs_to(*attrs)
55
- associate(:belongs_to, attrs)
56
- end
57
-
58
- def self.has_many(*attrs)
59
- associate(:has_many, attrs)
60
- end
61
-
62
- def self.associate(type, attrs)
63
- self._associations = _associations.dup
64
-
65
- associate_attributes(type, attrs)
66
- end
67
-
68
- def self.associate_attributes(type, attrs)
69
- options = attrs.extract_options!
70
-
71
- attrs.each do |attr|
72
- next if method_defined?(attr)
73
-
74
- define_method_attribute(attr)
75
-
76
- _associations[attr] = { type: type, options: options }
77
- end
78
- end
79
-
80
- def self.define_method_attribute(attr)
81
- options = attrs.extract_options!
82
-
83
- define_method attr do
84
- value = instance_variable_get("@_#{attr}")
85
- return value if value
86
-
87
- association = object.send(attr)
88
- return nil if association.blank?
89
-
90
- drop_instance = Archangel::Liquid::Drop.dropify(association, options)
91
-
92
- instance_variable_set("@_#{attr}", drop_instance)
93
- end
94
- end
95
-
96
34
  def initialize(object, _options = {})
97
35
  @object = object
98
36
  end
@@ -112,10 +50,6 @@ module Archangel
112
50
  as_json.to_json(options)
113
51
  end
114
52
 
115
- def before_method(method)
116
- attributes[method.to_s]
117
- end
118
-
119
53
  def inspect
120
54
  "#<#{self.class.name} " \
121
55
  "@object: #{object.inspect} @attributes: #{attributes.inspect}>"