Skip to content

Commit

Permalink
Prefix sir_trevor to defined getters to avoid overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
zamakkat committed Apr 26, 2016
1 parent a505b9a commit 0a88182
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ sir_trevor_content :content
In your view files, call render to display the Sir Trevor content

```ruby
<%= render @item.content %>
<%= render @item.sir_trevor_content %>
```
## Handling image uploads
Expand Down
6 changes: 3 additions & 3 deletions lib/sir_trevor_rails/has_sir_trevor_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def sir_trevor_content(*attributes)

private
def define_attribute_reader(attribute)
define_method attribute do
define_method "sir_trevor_#{attribute}" do
content = read_attribute(attribute)
return SirTrevorRails::BlockArray.new if content.blank?
instance_variable_get("@#{attribute}") ||
instance_variable_set("@#{attribute}", SirTrevorRails::BlockArray.from_json(content, self))
instance_variable_get("@sir_trevor_#{attribute}") ||
instance_variable_set("@sir_trevor_#{attribute}", SirTrevorRails::BlockArray.from_json(content, self))
end
end
end
Expand Down

0 comments on commit 0a88182

Please sign in to comment.